package com.yic.module.qms.dal.mysql.inspectscheme;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.qms.dal.dataobject.inspectscheme.InspectSchemeDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.qms.controller.admin.inspectscheme.vo.*;

/**
 * 检验方案 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface InspectSchemeMapper extends BaseMapperX<InspectSchemeDO> {

    default PageResult<InspectSchemeDO> selectPage(InspectSchemePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<InspectSchemeDO>()
                .likeIfPresent(InspectSchemeDO::getName, reqVO.getName())
                .eqIfPresent(InspectSchemeDO::getCode, reqVO.getCode())
                .eqIfPresent(InspectSchemeDO::getInspectType, reqVO.getInspectType())
                .eqIfPresent(InspectSchemeDO::getStatus, reqVO.getStatus())
                .eqIfPresent(InspectSchemeDO::getFactoryId, reqVO.getFactoryId())
                .orderByDesc(InspectSchemeDO::getId));
    }

    default List<InspectSchemeDO> selectList(InspectSchemeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<InspectSchemeDO>()
                .likeIfPresent(InspectSchemeDO::getName, reqVO.getName())
                .eqIfPresent(InspectSchemeDO::getCode, reqVO.getCode())
                .eqIfPresent(InspectSchemeDO::getInspectType, reqVO.getInspectType())
                .eqIfPresent(InspectSchemeDO::getStatus, reqVO.getStatus())
                .eqIfPresent(InspectSchemeDO::getFactoryId, reqVO.getFactoryId())
                .orderByDesc(InspectSchemeDO::getId));
    }

    default InspectSchemeDO selectByCode(String code) {
        return selectOne(new LambdaQueryWrapperX<InspectSchemeDO>()
                .eq(InspectSchemeDO::getCode, code));
    }
}
